package com.nondo.dean.order.model.param;

import org.apache.commons.lang3.StringUtils;

public class ConfirmOrderParam {
    /**
     * 类型:1.立即购买2.购物车结算
     */
    private Integer type;
    
    /**
     * 产品ID
     */
    private Integer productId;
    
    /**
     * 产品数量
     */
    private Integer num;
    
    
    /**
     * 定制内容
     */
    private String note;

    /**
     * 购物车ID字符串
     */
    private String cartIds;

    /**
     * @return the type
     */
    public Integer getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(Integer type) {
        this.type = type;
    }

    /**
     * @return the productId
     */
    public Integer getProductId() {
        return productId;
    }

    /**
     * @param productId the productId to set
     */
    public void setProductId(Integer productId) {
        this.productId = productId;
    }

    /**
     * @return the num
     */
    public Integer getNum() {
        return num;
    }

    /**
     * @param num the num to set
     */
    public void setNum(Integer num) {
        this.num = num;
    }

    /**
     * @return the note
     */
    public String getNote() {
        return note;
    }

    /**
     * @param note the note to set
     */
    public void setNote(String note) {
        this.note = note;
    }

    /**
     * @return the cartIds
     */
    public String getCartIds() {
        return cartIds;
    }

    /**
     * @param cartIds the cartIds to set
     */
    public void setCartIds(String cartIds) {
        this.cartIds = cartIds;
    }
    
    /**
     * 客户端输入参数校验
     * @param param {@link ConfirmOrderParam}
     * @return 字符串 错误提示
     */
    public static String checkeInputParam(ConfirmOrderParam param) {
        String message = null;
        Integer type = param.getType();
        if (type == null) {
            message = "输入类型不合法";
        } else if (type == 1 && param.getProductId() == null) {
            message = "请输入产品ID";
            if (param.getNum() == null||param.getNum() == 0) {
                message = "请输入有效的产品数量";
            }
        } else if (type == 2 && StringUtils.isBlank(param.getCartIds())) {
            message = "请输入产品购物车ID";
        }
        return message;
    }

}
